package com.szxy.content.controller;

import com.szxy.content.service.ContentService;
import com.szxy.pojo.TbContent;
import com.szxy.pojo.TbContentCategory;
import com.szxy.utils.ContentAD;
import com.szxy.utils.PageResult;
import com.szxy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther:zwer
 * @Date:2019/9/9 21:13
 * @Description:com.szxy.content.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/service/content")
public class ContentController {

    @Autowired
    private ContentService contentService;

    /**
     * 查询内容列表
     *
     * @param categoryId 内容分类目录 ID
     * @param page       页码
     * @param rows       每页显示的行数
     * @return
     */
    @GetMapping("/selectTbContentAllByCategoryId")
    PageResult selectTbContentAllByCategoryId(@RequestParam("categoryId") Long categoryId,
                                              @RequestParam("page") Integer page,
                                              @RequestParam("rows") Integer rows) {
            return this.contentService.selectTbContentAllByCategoryId(categoryId, page, rows);

    }

    /**
     * 插入内容
     * @param content
     * @return
     */
    @PostMapping("/insertTbContent")
    int insertTbContent(@RequestBody  TbContent content){
        return this.contentService.insertTbContent(content);
    }

    /**
     * 删除内容
     * @param ids  节点信息
     * @return
     */
    @PostMapping("/deleteContentByIds")
    Integer deleteContentByIds(@RequestParam("ids") Long ids){
        return this.contentService.deleteContentByIds(ids);
    }

    /**
     * 查询所有前台大广告
     * @return
     */
    @PostMapping("/selectFrontendContentByAD")
    List<ContentAD> selectFrontendContentByAD(){
        return this.contentService.selectFrontendContentByAD();
    }


}
